Repository navigation
fix(base): 页面在同一次事件里重画时,不再把事件投递第二遍 - #90
Open
xiaoyumuxi wants to merge 1 commit into
Open
xiaoyumuxi wants to merge 1 commit into
xiaoyumuxi wants to merge 1 commit into
Conversation
This was referenced Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
base/page.go:Page.Draw有时要在同一次 Draw 里撤回已画的内容再画一遍,原因可能是容器查询的答案与布局不符、Memo 复制失败、List 锚点移动,或 TextArea 请求重新布局。现在第二次声明前用Canvas.SuspendDelivery把这次事件挡在外面,画完再用ResumeDelivery放回;Draw的注释同步说明了这一点。gfx/canvas.go:新增Delivery类型和Canvas.SuspendDelivery、Canvas.ResumeDelivery。Clicked、ClickedIn、ClickTarget、ClickInfo、PointerOn、PointerIn、PointerPass都不回答,Delivering为 false,AfterPaint和Consume不起作用。ui/repaint_delivery_test.go、gfx/identity_test.go的TestSuspendedDeliveryIsReadOnlyUntilResumed。Why
ui.Container。在这两页按侧栏快捷键,侧栏折叠后马上又展开,看起来没反应。Lithe 的TestSidebarFoldsAwayAndComesBackWhereItWas因此失败。settleContainers把retry设为真,Draw就Rewind再执行一次 View。可这时还在同一次事件处理里,Clicked(id)仍然为真(要到EndEventPass才清掉),所以处理函数又跑了一遍。Rewind只撤回画出的内容,处理函数改过的状态撤不回。点击、Enter、ui.Shortcut、鼠标键快捷键、PointerOn按下都受影响,c.After推迟的函数也会执行两次。How it was verified
gofmt、go vet ./...,以及 darwin vivahead、windows、linux、js/wasm 的平台 vet,全部通过。TestAPaintDoneAgainDeliversTheEventOnce覆盖 Enter、点击、c.After、ui.Shortcut、mouse_back快捷键和PointerOn按下。修复前六条路径全部失败(处理函数跑 2 次),修复后全部通过。go test ./... -count=1:ui、gfx全部通过。base的指南与 Table hit 数;cmd/viva的生成文件过期与 min_system;components、tools/docs的 dock 文档;internal/gallery的 OTP 焦点;internal/layering的 frametrace 分层;internal/platform/darwin链接时缺 IOSurface;tools/visualparity的 dialog 偏移。go.work指向本分支:TestSidebarFoldsAwayAndComesBackWhereItWas原样通过,用量页变体也通过,-tags dev ./internal/aiwindow全包通过。deliverClick/deliverPointer。Where the boundary sits
一次事件只投递一次,与页面绘制几遍无关,这是框架的事件投递语义,属于 Viva,不在 Lithe 里绕过。合入后 Lithe 更新固定的 commit;同一分支已向上游 vivaui/viva 提 PR。
Cost
不重画的帧只多一个判断;重画时多两次结构体拷贝,不分配内存。
Known limits
Draw最多重画一次的上限没有改。RequestRelayout走同一个循环,这次一起修了,但没有单独的测试。